<%--
 *  File:    ChartofGLAccountEdit.jsp
 *  @Author: Stephen Liu
 *  Date:    Friday, January 16, 2004

 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType ="text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  Category cat = Category.getInstance("jsp.ChartofGLAccountEdit");
  String strModuleName = "GL";
  String privilegeCode = "40108";
  String strTableName = "ovglaccountlistsummary";
%>

<%@include file="/inc/PageDefault.inc" %>
<%@include file="/inc/SessionTimeout.inc" %>
<%@include file="/inc/Security.inc" %>

<html>
<head>
<title>chartofglaccountedit</title>
<PageFlow:CheckPageFlow pageName="chartofglaccountedit"/>
<%@include file="/inc/InitEdit.inc" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../css/<%= strLanguageCode %>/Calendar.js"></script>
<script language="JavaScript" src="../js/ScriptLib.js"></script>
<script language="JavaScript">

<% if (request.getParameter("hassaved") != null) { %>
  parent.up.location.href = "ChartofGLAccountSummary.jsp?<%= OvalTools.randomURL() %>";
  self.location.href = "../common/Blank.jsp?<%= OvalTools.randomURL() %>";
<% } %>

function page_save() {
  if (!checkForm(frm))
    return;

  var structure = Trim(frm.glaccountstructure.value);
  if (structure.indexOf("0") > -1) {
    alert("<%= message.getMessageDesc("GLACCS_CANNOT_CONTAIN_0") %>");
    return;
  }
  var grade = calGrade(structure);
  if (grade == null) {
    alert('<%= message.getMessageDesc("SUM_OF_DIGITS_NOT_MORETHAN", label.getLabelName("L_GLAccountStructure", false), "16") %>');
    return;
  }
  for (var i = 1; i <= 6; i ++)
    eval("frm.grade" + i).value = grade[i];
  frm.gradecount.value = structure.length;

  MLCSTransform(frm);
  formatCheckBox(frm);

  frm.actionname.value = "save";
  isRunning = true;
  frm.submit();
}

function page_export() {

}

function calGrade(structure) {
  var grade = new Array(0, 0, 0, 0, 0, 0, 0);
  var sum = 0;

  for (var i = 0; i < structure.length; i ++) {
    grade[i + 1] = grade[i] + Number(structure.charAt(i));
    sum += Number(structure.charAt(i));
  }

  if (sum <= 16)
    return grade;
  else return null;
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="frm" method="post" action="../Dispatcher">
  <input type="hidden" name="pagename" value="chartofglaccountedit">
  <input type="hidden" name="actionname">

  <custom:hidden name="glaccountlistinfo" property="glaccountlistid"/>
  <input type="hidden" name="gradecount">
  <input type="hidden" name="grade1">
  <input type="hidden" name="grade2">
  <input type="hidden" name="grade3">
  <input type="hidden" name="grade4">
  <input type="hidden" name="grade5">
  <input type="hidden" name="grade6">
  <custom:hidden name="userinfo" scope="session" property="orgid"/>
  <custom:hidden name="userinfo" scope="session" property="userid" changedName="maker"/>

  <input type="hidden" name="numrows" value="2">

<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2"><img src="../images/<%= strLanguageCode %>/quote.gif"> <%= label.getLabelName("L_New") %>/<%= label.getLabelName("L_Modify") + label.getLabelName("L_StaAccountList") + label.getLabelName("L_Colon") %></td>
  </tr>
</table>
<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">
      <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">
        <tr>
          <td width="107" class="td-text" height="20"><%= label.getLabelName("L_SubjectCode") + label.getLabelName("L_Colon") %></td>
          <td width="300">
            <custom:write name="glaccountlistinfo" property="glaccountlistcode"/>
          </td>
          <td class="td-text" width="110"><%= label.getLabelName("L_CreateDate") + label.getLabelName("L_Colon") %></td>
          <td>
            <custom:write name="glaccountlistinfo" property="createdate" dataFormatName="dateformat"/>
         </td>
        </tr>
        <tr>
          <td class="td-text"><%= label.getLabelName("L_RptDescription") + label.getLabelName("L_Colon") %></td>
          <td height="18" colspan="3">
            <custom:text name="glaccountlistinfo" property="description" size="75" needMLC="true" isFirstMLC="true" multiLangType="description" entityId="glaccountlistid" contentId="glaccountlistlangid" colIndex="0"/>
            <a onclick='popup("../common/Lang.jsp?<%= OvalTools.randomURL() %>&form=frm&module=GL&mlctype=L_Description&nativelanguage=&schema=ovglaccountlistlang&qlname=selectbyid&entityid=<custom:write name="glaccountlistinfo" property="glaccountlistid"/>&entitytype=description&contentid=glaccountlistlangid&colindex=0","newwindow","height=250,width=320,top=100,left=100,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");'><custom:button type="3" label="L_Ln" imgsrc="ln.gif" border="0"/></a>
          </td>
        </tr>
        <tr>
          <td class="need"><%= label.getLabelName("L_GLAccountStructure") + label.getLabelName("L_Colon") %></td>
          <td>
            <custom:text name="glaccountlistinfo" property="glaccountstructure" dataType="number" command="notnull" module="GL" label="L_GLAccountStructure" maxlength="6"/>
          </td>
          <td class="need"><%= label.getLabelName("L_Status") + label.getLabelName("L_Colon") %></td>
          <td>
            <custom:select name="glaccountlistinfo" property="status" optionsName="allstatus" optionValueKey="statuscode" optionInnerTextKey="statusname"/>
          </td>
        </tr>
        <tr>
          <td class="td-text" height="20"><%= label.getLabelName("L_AllowCreateTopAccount") + label.getLabelName("L_Colon") %></td>
          <td>
            <custom:checkbox name="glaccountlistinfo" property="createtopaccountflag" checkFlag="1/0" style="border:0"/>
          </td>
          <td class="td-text"><%= label.getLabelName("L_Maker") + label.getLabelName("L_Colon") %></td>
          <td>
            <custom:write name="userinfo" scope="session" property="username" nbsp="true"/>
          </td>
        </tr>
        <tr>
          <td class="need"><%= label.getLabelName("L_LocationCurrency") + label.getLabelName("L_Colon") %></td>
          <td>
            <custom:select name="glaccountlistinfo" property="currencycode" optionsName="allcurrencies" optionValueKey="currencycode" optionInnerTextKey="currencyname"/>
          </td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td class="td-text" height="20"><%= label.getLabelName("L_Comments") + label.getLabelName("L_Colon") %></td>
          <td colspan="3">
            <custom:textarea name="glaccountlistinfo" property="comments" cols="74" rows="4"/>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td class="td_center">
      <a onclick="javascript:page_save()"><custom:button type="1" label="L_Save" border="0" style="width:60"/></a>
      <a onclick="javascript:self.location.href='../common/Blank.jsp?<%= OvalTools.randomURL() %>'"><custom:button type="1" label="L_Back" border="0" style="width:60"/></a>
      <!--a onclick="javascript:page_export()"><custom:button type="1" label="L_ExportGLAccountList" border="0"/></a-->
    </td>
  </tr>
</table>
</form>
</body>
</html>
